import React from 'react';
import './index.css';

class HelloWorld extends React.Component {
  static defaultProps = {
    content: '默认内容，还没有文本',
  };

  state = {
    times: 0,
    // mood: 100,
  };

  componentDidMount() {
    setInterval(() => {
      this.state.times++; // bad
      // this.setState({ mood: this.state.mood + 100 }); // ok
    }, 1000);
  }

  render() {
    return (
      <div className="hello-world">
        <h1>{this.props.content} -</h1>
        <p>{this.state.times}</p>
        {/* <p>{this.state.mood}</p> */}
      </div>
    );
  }
}

export default HelloWorld;
